﻿using JobRecruitment.Entities;
using System;
using System.Collections.Generic;
using System.Linq;

namespace JobRecruitment.Models
{
    public class RequriementFilterViewModel
    {
        public string RequriementKey { get; set; }
        public List<string> RequriementItems { get; set; }
        public string Selected { get; set; }

        //public List<string> Educations { get; set; }
        //public List<string> Welfares { get; set; }
        //public List<string> Cities { get; set; }

        private readonly JobRecruitmentContext _context;

        public RequriementFilterViewModel()
        {

        }

        public RequriementFilterViewModel(JobRecruitmentContext context)
        {
            _context = context ?? throw new ArgumentNullException(nameof(context));
        }

        public List<RequriementFilterViewModel> GetRequriement()
        {
            var requriements = new List<RequriementFilterViewModel>
            {
                new RequriementFilterViewModel
                {
                    RequriementKey = "工作经验",
                    RequriementItems = _context.Requirements.Select(m => m.Educations).Where(m => !string.IsNullOrEmpty(m)).ToList(),
                    Selected = null
                },
                new RequriementFilterViewModel
                {
                    RequriementKey = "工作福利",
                    RequriementItems = _context.Requirements.Select(m => m.Welfares).Where(m => !string.IsNullOrEmpty(m)).ToList(),
                    Selected = null
                },
                new RequriementFilterViewModel
                {
                    RequriementKey = "所在城市",
                    RequriementItems = _context.Cities.Select(m => m.CityName).ToList(),
                    Selected = null
                }
            };
            return requriements;
        }
    }
}
